package cn.itsource.feign.fallback;

import cn.itsource.domain.Login;
import cn.itsource.dto.LoginMealDto;
import cn.itsource.feign.client.LoginFeign;
import cn.itsource.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 兜底类
 * @Author: Jason
 * @Date: 2022/8/29 21:20
 */
@Component
public class LoginFeignFallbcakFactory implements FallbackFactory<LoginFeign> {

    @Override
    public LoginFeign create(Throwable throwable) {
        return new LoginFeign(){
            @Override
            public JSONResult save(Login login) {
                throwable.printStackTrace();
                return JSONResult.error("Auth服务不可用-保存信息到t_login表失败，请稍后再试");
            }

            @Override
            public JSONResult saveLoginMeal(LoginMealDto dto) {
                throwable.printStackTrace();
                return JSONResult.error("Auth服务不可用-保存信息到t_login_meal表失败，请稍后再试");
            }
        };
    }
}
